package com.bawei.model_sevent.Activity.Fragemnt;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;

import com.alibaba.android.arouter.launcher.ARouter;
import com.bawei.model_sevent.Activity.Adapter.ClassAdapter;
import com.bawei.model_sevent.Activity.Banner.BannerBean;
import com.bawei.model_sevent.Activity.Banner.BannerContent;
import com.bawei.model_sevent.Activity.Banner.BannerModel;
import com.bawei.model_sevent.Activity.Banner.BannerPreson;
import com.bawei.model_sevent.R;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemChildClickListener;

import org.jetbrains.annotations.NotNull;

import java.util.List;

public class BlankFragment1 extends Fragment implements BannerContent.View {
    private RecyclerView recy01;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View inflate = inflater.inflate(R.layout.fragment_blank1, container, false);
        recy01 = inflate.findViewById(R.id.recy_01);
        recy01.setLayoutManager(new StaggeredGridLayoutManager(3,StaggeredGridLayoutManager.VERTICAL));
        BannerPreson bannerPreson = new BannerPreson(new BannerModel(), this);
        bannerPreson.GetDate("1","10");
        return inflate;
    }

    @Override
    public void initAdapter(List<BannerBean.DataBean> bannerList) {
        ClassAdapter classAdapter = new ClassAdapter(bannerList);
        recy01.setAdapter(classAdapter);
        classAdapter.setOnItemChildClickListener(new OnItemChildClickListener() {
            @Override
            public void onItemChildClick(@NonNull @NotNull BaseQuickAdapter adapter, @NonNull @NotNull View view, int position) {
                Fragment fragment= (Fragment) ARouter.getInstance()
                        .build("/shopping/one")
                        .withString("name",bannerList.get(position).getCategoryName())
                        .withString("images", bannerList.get(position).getPictUrl())
                        .navigation();
            }
        });
    }
}